package com.example.xpagedemoproject.fragment;

import com.example.xpagedemoproject.ContainerActivity;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.base.XPageSimpleListFragment;
import com.xuexiang.xpage.core.PageOption;
import com.xuexiang.xpage.enums.CoreAnim;

import java.util.List;

@Page(name = "PageOption使用")
public class PageOptionFragment extends XPageSimpleListFragment {
    @Override
    protected List<String> initSimpleData(List<String> lists) {
        lists.add("普通打开");
        lists.add("设置动画");
        lists.add("是否支持数据返回");
        lists.add("打开新的Activity");
        lists.add("使用自定义的容器打开新的Activity");
        lists.add("返回至指定的页面");
        return lists;
    }

    @Override
    protected void onItemClick(int position) {
        PageOption pageOption = new PageOption(TestFragment.class);
        switch (position) {
            case 0:
                pageOption.setTargetPage(AnimationFragment.class);
                break;
            case 1:
                pageOption.setAnim(CoreAnim.zoom);
                break;
            case 2:
                pageOption.setRequestCode(100)
                        .putBoolean(DataReceiveFragment.KEY_IS_NEED_BACK,true);
                break;
            case 3:
                pageOption.setNewActivity(true);
                break;
            case 4:
                pageOption.setNewActivity(true, ContainerActivity.class);
                break;
            case 5:
                pageOption.putString(TestFragment.KEY_TOP_BACK_NAME,"XPage");
                break;
            default:
                break;
        }
        pageOption.open(this);

    }
}
